package ar.com.fiuba.domain.impl.misspell;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import ar.com.fiuba.application.api.DataSource;
import ar.com.fiuba.application.impl.FileDataSource;

public abstract class MisspelledWordsGenerator {

	protected List<String> correctWordsArray = new ArrayList<String>();

	public List<String> getCorrectWordsArray() {
		return correctWordsArray;
	}

	public MisspelledWordsGenerator(String inputFileName, int numberOfWords) {
		DataSource correctWordsFile;
		try {
			correctWordsFile = new FileDataSource(inputFileName);
		} catch (IOException e) {
			// We assume file exists
			e.printStackTrace();
			return;
		}

		int i = 0;
		while (correctWordsFile.hasDataLeft() && i < numberOfWords) {
			String aux = correctWordsFile.getNextWord();
			if (aux.length() > 2) {
				correctWordsArray.add(aux);
				i++;
			}
		}
	}

	public abstract List<String> generateErrorAtTheBeginning();

	public abstract List<String> generateErrorAtTheEnd();

	public abstract List<String> generateErrorInTheMiddle();

	public abstract String getFileNamePrefix();

}
